package com.dragon.repository.domain.dto;

import com.dragon.repository.entity.Site;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SiteDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "经度")
    private Double longitude;

    @ApiModelProperty(value = "纬度")
    private Double latitude;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "详细地址")
    private String address;

    @ApiModelProperty(value = "用户名称")
    private String username;


    public SiteDTO() {}

    public SiteDTO(Site entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static SiteDTO convert(Site entity) {
        return new SiteDTO(entity);
    }

    public static List<SiteDTO> convertList(List<Site> list) {
        List<SiteDTO> resultList = new ArrayList<>();
        for (Site entity : list) {
            resultList.add(new SiteDTO(entity));
        }
        return resultList;
    }}
